package com.wobaby.junit.tsetyuhao;

import java.sql.Connection;
import java.util.ArrayList;

import org.junit.Test;

import com.wobaby.dao.MessagerContentManagement;
import com.wobaby.dao.RoleManagement;
import com.wobaby.util.C3P0Utils;
import com.wobaby.vo.MessagerContentVO;
import com.wobaby.vo.RoleVO;

public class DBTest {

	//RoleVO re=new RoleVO(2, "yuhao", "huanli", "qunbu", "tset", "nihao");
	@Test
	public void test() throws Exception {
//		fail("Not yet implemented");	
		C3P0Utils db=new C3P0Utils();
		Connection con=db.getConnection();
		System.out.println(con);
		
	//	RoleVO re=new RoleVO(3, "yuhao", "huanli", "qunbu", "tset", "nihao");
		//RoleManagement ro= new RoleManagement();
		//ro.addRole(re);
		//ro.removeRole(re);
		//ArrayList list= new ArrayList();
	//	list=(ArrayList) ro.listAllRoles();
	//System.out.println(list);
	
//		con.close();
		//Connection co=db.getConnection();
		//System.out.println(co);
	}
	@Test
	public void test2()
	{
		//RoleVO re=new RoleVO(4, "yuhao", "huanli", "qunbu", "tset", "nihao");
		C3P0Utils db=new C3P0Utils();
		Connection con=db.getConnection();
		System.out.println(con);
		RoleManagement ro=new RoleManagement();
		//ro.addRole(re);
		RoleVO rolevo=ro.lookupRoleByID(2);
		System.out.println(rolevo);
		System.out.println(ro.hasPermissionForRole(1, rolevo));
		
	}
	@Test
	public void test3()
	{
		Connection con=C3P0Utils.getConnection();
		System.out.println(con);
		MessagerContentManagement dao=new MessagerContentManagement();
		ArrayList list=(ArrayList) dao.listAllmessageID();
		//System.out.println(list);
		//ArrayList<String> li= (ArrayList<String>) dao.listAllMessagerContentTitile();
		//System.out.println(li);
		//System.out.println(dao.listMessagerContent());
		//MessagerContentVO vo= new MessagerContentVO();
		ArrayList<MessagerContentVO> list3= (ArrayList<MessagerContentVO>) dao.listMessagerContent();
		//System.out.println(list3);
		for(int i=0;i<list3.size();i++)
		{
			
			//System.out.println(list.get(i));
			MessagerContentVO vo= new MessagerContentVO();
			vo=list3.get(i);
			System.out.println(vo.getContent());
			//vo= (MessagerContentVO) list.get(i);
			//System.out.println(vo);
			//System.out.println(vo);
			//System.out.println(vo.getContentID());
		}
		
	}

}
